<template>
  <el-dialog :title="'交易详情'" :visible.sync="dialogFormVisible" style="margin: auto;width: 70%" center>
    <div style="margin: auto" class="fontC">
      <el-form label-width="150px">
        <el-form-item label="交易id：">
          <span v-text="userFundLog.id"></span>
        </el-form-item>
        <el-form-item label="支付人：">
          <span v-text="userFundLog.payUserId"></span>
        </el-form-item>
        <el-form-item label="收款方：">
          <span v-text="'系统'"></span>
        </el-form-item>
        <el-form-item label="交易号：">
          <span v-text="userFundLog.tradeNumber"></span>
        </el-form-item>
        <el-form-item label="支付类型：">
          <el-tag size="medium">{{ global.PayType[userFundLog.payType]}}</el-tag>
        </el-form-item>
        <el-form-item label="支付状态：">
          <el-tag size="medium">{{ global.PayState[userFundLog.payState]}}</el-tag>
        </el-form-item>
        <el-form-item label="业务类型：">
          <el-tag size="medium">{{global.UserFundModeType[userFundLog.modeType]}}</el-tag>
        </el-form-item>
        <el-form-item label="业务关联id：">
          <span v-text="userFundLog.modeId"></span>
        </el-form-item>
        <el-form-item label="创建时间：">
          <i class="el-icon-time" v-if="userFundLog.createTime"></i>
          <span style="margin-left: 10px">{{ userFundLog.createTime }}</span>
        </el-form-item>
        <el-form-item label="支付时间：">
          <i class="el-icon-time" v-if="userFundLog.payTime"></i>
          <span style="margin-left: 10px">{{ userFundLog.payTime }}</span>
        </el-form-item>
        <el-form-item label="最近修改时间：">
          <i class="el-icon-time" v-if="userFundLog.updateTime"></i>
          <span style="margin-left: 10px">{{ userFundLog.updateTime }}</span>
        </el-form-item>
        <el-form-item>

        </el-form-item>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
     <el-button  v-if="isAuth('simida:userfundlog:update')" type="warning" @click="compensate">订单补偿</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import enums from '@/common/enum'

  export default {
    name: "userfundlog-info",
    data() {
      return {
        logId: '',
        dialogFormVisible: false,
        userFundLog: '',
        global: enums,
      }
    },
    methods: {
      details(logId) {
        this.logId = logId;
        this.$http({
          url: this.$http.adornUrl(`/simida/userfundlog/info/` + logId),
          method: 'get',
          params: this.$http.adornParams({}, false)
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dialogFormVisible = true;
            this.userFundLog = data.userFundLog;
          } else {
            this.$message.error(data.msg);
          }
        })
      },
      //订单补偿
      compensate(){
        let tradeNos= [this.userFundLog.tradeNumber];
        this.$confirm(`确定对[订单号=${tradeNos.join(',')}]进行补偿操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/simida/userfundlog/compensate'),
            method: 'put',
            data: this.$http.adornData(tradeNos, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.dialogFormVisible = false
                  this.$emit('refreshDataList')
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>

<style scoped>
  .fontC {
    font-size: 20px
  }
</style>
